#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"

void prsanykey(){
		char anykey;
		printf("按任意键退出...\n");

		system("bash -c \"read -n1 -s\"");
		scanf("%c", &anykey);
	
}


int passwd(){
        char pwd[25];
        char storage_pwd[25];
        printf("请输入密码：");
        scanf("%s", pwd);
        FILE* fp = fopen("./usrcnt", "r");
	fseek(fp, sizeof(int), SEEK_SET); //跳过id计数，读取密码

	int bytes_read = fread(storage_pwd, 1, sizeof(storage_pwd) - 1, fp);
	storage_pwd[bytes_read] = '\0';

	if(strcmp(pwd, storage_pwd) == 0){
		printf("密码输入正确！\n");
		return 1;
        }

        else{
                printf("密码输入错误！\n");
                return 0;
        }

	fclose(fp);
}


